feat(agent): add workflow revert & redo for AI agent turns#6211
Draft
sshiv012 wants to merge 1 commit into
Draft
feat(agent): add workflow revert & redo for AI agent turns#6211sshiv012 wants to merge 1 commit into
sshiv012 wants to merge 1 commit into
Conversation
Per-turn "Revert" rewinds the workflow and the agent-service HEAD to before a turn; a toolbar "Redo" undoes the revert (redo stack, cleared on new prompt). Reuses the ReAct step version-tree + per-step snapshots; adds WsClientRevert/ RedoCommand and WsServerHeadChangeEvent, with revert/redo blocked while the agent is busy and the connect snapshot carrying workflow content for reconnects. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
👋 Thanks for your first contribution to Texera, @sshiv012! If you're looking for a good place to start, browse issues labeled You can drive common housekeeping yourself by commenting one of these commands on its own line:
Each command must match exactly: |
Contributor
Automated Reviewer SuggestionsBased on the
|
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
The Texera AI agent edits the user's live workflow canvas, its tools add, modify, and delete operators, and the changes auto-persist. Until now there was no agent-aware way to back out a turn that went wrong; the user had to manually undo a multi-operator change. This PR adds two controls:
HEAD) to the statebefore an agent turn.
reverts→redos, and is cleared when a new prompt starts a new branch.
Use case / why: the agent mutates real state, so a bad suggestion (a wrong delete, an unwanted restructure) is expensive to recover from. A cheap, reliable "step back" lowers the cost of letting the agent experiment. A frontend-only visual undo is insufficient, the agent-service keeps its own
HEAD, so the next message would silently clobber a cosmetic revert. This does a true rewind that keeps the agent's context consistent.How it works: the agent-service already models a conversation as a version tree of ReAct steps (
id/parentId+beforeWorkflowContent/afterWorkflowContentsnapshots + aHEADpointer).The only missing primitive was moving
HEADbackward.HEAD ← parent(T), restoreT.beforeWorkflowContent, push old HEAD onto an in-memory redo stack (reverted steps stay in the tree, nothing is deleted).HEADforward, restore that step'safterWorkflowContent.GENERATING, to avoid racing the loop's own HEAD/workflow mutations.Protocol additions:
WsClientRevertCommand { messageId },WsClientRedoCommand(client→server);WsServerHeadChangeEvent { headId, workflowContent, canRedo }and acanRedofield onWsServerSnapshotEvent(server→client, so a reconnecting client renders the correct Redo state).No new persistence, no schema changes, no new services; revert/redo state is the in-memory step tree the agent already maintains.
Scoped as follow-ups: per-individual-step revert, forward/branch navigation UI beyond single-level redo, and persisting revert history across agent-service restarts (currently session-scoped).
Any related issues, documentation, discussions?
Design discussion / RFC: #6039
How was this PR tested?
New automated tests were added and all existing suites pass:
revertToTurnStart/redo/canRedo, clear-on-new-prompt, and the WS command handlers including reject-while-generating, unknown-turn, and nothing-to-redo negative cases.WsServerHeadChangeEventhandler (HEAD update +canRedo+ canvas reload), therevertTurn/redosenders, and the button enable/disable logic.Full local run of the CI pipeline for both services (rebased on latest
main) passes:format/typecheck/bun test(agent-service), andformat:ci/build:ci/test:ci/ browser-mode tests (frontend).Manual: agent adds operators → Revert rolls them back → Redo restores them → sending a new message branches and clears Redo.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)
What changes were proposed in this PR?
Any related issues, documentation, discussions?
How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?